const config = require('./webpack/lib/config');

const isDEV = config.APP_ENV === 'dev'; // 是否是开发模式

module.exports = {
  // targets: '>1%, not ie 11',
	presets: [
		['@babel/preset-env',
			{
				loose: false,
			}
		],
		'@babel/preset-react',
		'@babel/preset-typescript'
	],
  plugins: [
    // "lodash",
    '@babel/plugin-transform-runtime',
    "@babel/plugin-syntax-jsx",
    [
      "@babel/plugin-transform-react-jsx",
      {
        "throwIfNamespace": false, // defaults to true
        "runtime": "automatic", // defaults to classic
        // "importSource": "custom-jsx-library" // defaults to react
      }
		],
		// ["import", {
    //   "libraryName": "antd",
    //   "libraryDirectory": "es",
    //   "style": "css" // `style: true` 会加载 less 文件
    // }],
    ['@babel/plugin-proposal-decorators', { legacy: true }],
    '@babel/plugin-transform-react-constant-elements',
    'macros',
    '@babel/plugin-syntax-dynamic-import',
    [
      '@babel/plugin-proposal-class-properties',
      {
        loose: true,
      },
    ],
    "@babel/plugin-proposal-export-default-from",
    [
      "@babel/plugin-proposal-private-methods",
      {
        loose: true,
      }
    ],
    [
      "@babel/plugin-proposal-private-property-in-object",
      {
        loose: true,
      }
    ],
    // "@babel/plugin-proposal-numeric-separator",
    // "@babel/plugin-proposal-optional-chaining",
    // "@babel/plugin-proposal-nullish-coalescing-operator",
    isDEV && ['react-refresh/babel'],
  ].filter(Boolean),
};
